package com.pretty.test.controller.pets.blog;


import com.baomidou.mybatisplus.extension.api.R;
import com.pretty.test.controller.pets.blog.dto.BlogPageDTO;
import com.pretty.test.controller.pets.blog.vo.BlogPageVO;
import com.pretty.test.entity.PetsBlog;
import com.pretty.test.service.IPetsBlogService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 博客控制器
 * @author dujianyu
 * @since 2021-04-08
 */
@RestController
@AllArgsConstructor
@RequestMapping("/blog")
public class PetsBlogController {

    private IPetsBlogService service;

    /**
     * 自定义列表
     * @param dto
     */
    @GetMapping("/list")
    public R<List<BlogPageVO>> list(BlogPageDTO dto){
        return R.ok(service.selectBlogPage(dto));
    }

    /**
     * 新增或修改
     * @param petsBlog
     */
    @PostMapping("/submit")
    public  R<Boolean> submit(@RequestBody PetsBlog petsBlog){
        return R.ok(service.saveOrUpdate(petsBlog));
    }

    /**
     * 逻辑删除
     * @param id
     */
    @PostMapping("/delete")
    public R<Boolean> delete(String id){
        return R.ok(service.removeById(id));
    }

}
